<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@include file="/WEB-INF/base.jspf"%>
<!DOCTYPE html>
<html>
<head>
<title>平台在线支付设置</title>
<style>
	.nav{
		display:flex;
		justify-content: center;
	}
	
	#new{
		width:15%;
		text-align: center;
		background: #555;
		color: #fff;
		padding:5px;
		cursor: pointer;
		margin-top:20px;
	}
	
	#type-list ul li span{
		font-size:14px;
	}

	.div-c-init{
		padding-top:30px;
	}
	.div-c-table {
		display:none;
		padding-top:16px;
	}
	.div-c-table-active {
		display:block;
	}
		.modal-dialog {
		max-width: 1000px;
	}
	.control-btns button + button {
		margin-left:10px;
	}
	table th,table tr,table td {
		text-align: center;
		vertical-align:middle;
	}
	#editPayOnLine .p-c-flexwrapper, #editQuickGetMoney .p-c-flexwrapper {
		display:flex;
		align-items:center;
		margin-bottom:16px;
		margin-right:16px;
	}
	
	#editPayOnLine1 .p-c-flexwrapper, #editQuickGetMoney .p-c-flexwrapper {
		display:flex;
		align-items:center;
		margin-bottom:16px;
		margin-right:16px;
	}
	#editPayOnLine .p-c-flexwrapper span, #editQuickGetMoney .p-c-flexwrapper span {
		width:110px;
		text-align: center;
	}
	
	#editPayOnLine1 .p-c-flexwrapper span, #editQuickGetMoney .p-c-flexwrapper span {
    width: 110px;
    text-align: center;
}
	#editPayOnLine .p-c-flexwrapper .form-control, #editQuickGetMoney .p-c-flexwrapper .form-control {
		width:200px;
	}
	
	#editPayOnLine1 .p-c-flexwrapper .form-control, #editQuickGetMoney .p-c-flexwrapper .form-control {
    width: 200px;
}
	#editPayOnLine .modal-body, #editQuickGetMoney .modal-body {
		display:flex;
		flex-wrap:wrap;
	}
	
	
	#editPayOnLine1 .modal-body, #editQuickGetMoney .modal-body {
		display:flex;
		flex-wrap:wrap;
	}
	.hiddenId-c {
		display:none;
	}
	.demo-list ul{
	
	display：block;
	width:380px;
	overflow:hidden;
	justify-content: center;
	align-items: center;
	font-size:14px;
	} 
	.demo-list ul li{
	    float:left;
	    width:45%;
	    margin-right:6px;
	     margin-top:6px;
	     margin-bottom:6px;
	    padding: 6px 12px;
	    border: 1px solid #ccc;
	    border-radius: 4px;
	}
</style>
</head>
<body>	
<div class="div-c-init"></div>
<div class="div-c-table div-c-table-active" id="div-c-table1">
	<table id="table-i-onlinePayTable" data-path='updateOnlineState' class="table-ajax-datatables table table-striped table-bordered table-hover">
		<thead>
			<tr>
				<th class="hiddenId-c"></th>	
				<th>接口名称</th>
				<th>商户编号</th>
				<th>下单秘钥</th>
				<th>支付秘钥</th>
				<th>接口地址</th>
				<th>最大金额</th>
				<th>最小金额</th>
				<th>接口操作</th>
			</tr>
		<tbody id="zhifuxiangqing"> </tbody> 
	</table>
</div>

	<!-- 修改的模态框（Modal） -->
	<div class="modal fade" id="editPayOnLine" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	    <div class="modal-dialog" style="width:860px;">
	        <div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	                <h4 class="modal-title" id="myModalLabel">修改支付设置</h4>
	            </div>
	            <div class="modal-body">
	            	<p class="p-c-flexwrapper">
	            		<span id="int-id" style="display:none;"></span>
	            		<span>接口名称</span>
	            		<input class="form-control" id="input-jiek"/>
	            	</p>
	            	<p class="p-c-flexwrapper">
	            		<span>商户账号</span>
	            		<input class="form-control" id="input-shbh"/>
	            	</p>
	            	<p class="p-c-flexwrapper">
	            		<span>下单秘钥</span>
	            		<input class="form-control" id="input-xdmy"/>
	            	</p>
	            	<p class="p-c-flexwrapper">
	            		<span>支付秘钥</span>
	            		<input class="form-control" id="input-zfmy"/>
	            	</p>
	            	<p class="p-c-flexwrapper">
	            		<span>最大金额</span>
	            		<input class="form-control" id="input-zdje"/>
	            	</p>
        		    <p class="p-c-flexwrapper">
	            		<span>最小金额</span>
	            		<input class="form-control" id="input-zxje"/>
	            	</p>
	            	<p class="p-c-flexwrapper">
	            		<span>支付接口地址</span>
	            		<input class="form-control" id="input-zfjkurl"/>
	            	</p> 
	            	<p class="p-c-flexwrapper">
	            		<span>接口查询地址</span>
	            		<input class="form-control" id="input-ydcxdz"/>
	            	</p>
	            	<p class="p-c-flexwrapper" style="margin:0; display:none">
	            		<span>支付方式编号</span>
	            		<input class="form-control" id="input-zufsbh"/>	
	            	</p> 
        		    <div class="demo-list clear">
				        <ul>
				         <!--  <li>
				            <input tabindex="1" type="checkbox" id="input-1" value="1">
				            <span>微信钱包</span>
				          </li> -->
				          <li>
				            <input tabindex="2" type="checkbox" id="input-2" value="2">
				            <span>微信扫码</span>
				          </li>
				         <!--   <li>
				            <input tabindex="3" type="checkbox" id="input-3" value="3">
				            <span>支付宝钱包</span>
				          </li> -->
				          <li>
				            <input tabindex="4" type="checkbox" id="input-4" value="4">
				            <span>支付宝扫码</span>
				          </li>
				         <!--  <li>
				            <input tabindex="5" type="checkbox" id="input-5" value="5">
				            <span>QQ钱包</span>
				          </li>
				          <li>
				            <input tabindex="6" type="checkbox" id="input-6" value="6">
				            <span>QQ扫码</span>
				          </li>
				          <li>
				            <input tabindex="7" type="checkbox" id="input-7" value="7">
				            <span>银联快捷</span>
				          </li>
				          <li>
				            <input tabindex="8" type="checkbox" id="input-8" value="8">
				            <span>银联扫码</span>
				          </li> -->
				        </ul>   		               		            			            		            	            		            	          	            		            	
					 </div>
	            </div>
	            <div class="modal-footer">
	                <button type="button" class="btn btn-primary">提交更改</button>
	                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	            </div>
	        </div><!-- /.modal-content -->
	    </div><!-- /.modal-dialog -->
	</div>
	
<script type="text/javascript">
	$(function(){
		findAllRechargeData();//查询所有的支付接口信息 
		$("#table-i-onlinePayTable").on("click", ".btn-editInterfaceInfo",updateRecharge);
		
	});	
	var faceData; 
	function findAllRechargeData(){
		$("#table-i-onlinePayTable").DataTable({
		    "bLengthChange": true,      
		    "bSort": false,
		    "bAutoWidth": false,
		    'aLengthMenu':[ 10, 20],
		     "searching": false,
		     "dom": "t<'tableinfo'i<'tableSearch'p>l>",
		     "language": {//语言设置  
		          "lengthMenu": "每页显示 _MENU_ 条记录",     
		          "zeroRecords": "没有检索到数据",
		          "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
		          "info": "没有数据",     
		          "oPaginate": {     
		              "sFirst": "首页",     
		              "sPrevious": "前一页",     
		              "sNext": "后一页",     
		              "sLast": "尾页"    
		        	},
		          "search":"搜索:",
		          "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
		          "infoEmpty":      "没有找到匹配的信息",
		       },	      
		       "columns": [
		    	   		   {"data": "id","className": "id-td hiddenId-c"},
						   {"data": "payName","className": "payName-td"},
		                   {"data": "p_UserId","className": "p_UserId-td"},
		                   {"data": "salfStr","className": "salfStr-td"},
						   {"data": "dealerURL","className": "dealerURL-td"},
		                   {"data": "payInterfaceURL","className": "payInterfaceURL-td"},
		                   {"data": "maxMoney","className": "maxMoney-td"},
		                   {"data": "minMoney","className": "minMoney-td"},
		                   {"data": null, "defaultContent": "<button class='btn btn-default btn-sm btn-editInterfaceInfo'>修改</button>"},
		               ],	         
		         "ajax": {
		      	 "url": "/admin/getRecharge.do",
		      	 "type": "post",
		      	 "data": function(data) {
		      			 return data;
		      	 },
		      	"dataSrc": function(result) {
		      		 faceData = result.data;
	        		 return faceData;
	        	 },				    	
		       },
		  })
	}
	
	 function updateRecharge(event) {
	 		$("#editPayOnLine").modal("show");
	 		var id = $(this).parents().children("td:eq(0)").text();
	 		for(var i in faceData){
	 			if(faceData[i].id==id){
	 				$('#int-id').text(faceData[i].id);
	 				$("#input-jiek").val(faceData[i].payName);
	 		 		$("#input-shbh").val(faceData[i].p_UserId);
	 		 		$("#input-xdmy").val(faceData[i].salfStr);
	 		 		$("#input-zfmy").val(faceData[i].dealerURL);
	 		 		$("#input-zxje").val(faceData[i].minMoney);
	 		 		$("#input-zdje").val(faceData[i].maxMoney);
	 		 		$("#input-zfjkurl").val(faceData[i].payInterfaceURL);
	 		 		$("#input-ydcxdz").val(faceData[i].payQueryURL);
	 		 		$("#input-shmc").val(faceData[i].shopName);
	 		 		$("#input-zufsbh").val(faceData[i].p_ChannelId);
		 		 	var spzhifu = faceData[i].p_ChannelId.split(",")
		 		 	for(var i = 0;i < spzhifu.length;i++){
		 		 		/* if(spzhifu[i] == $("#input-1").val()){
		 		 			$("#input-1")[0].checked=true;
		 		 		} */
	 					if(spzhifu[i] == $("#input-2").val()){
	 						$("#input-2")[0].checked=true;
		 		 		}
	 					/* if(spzhifu[i] == $("#input-3").val()){
	 						$("#input-3")[0].checked=true;
	 					} */
	 					if(spzhifu[i] == $("#input-4").val()){
	 						$("#input-4")[0].checked=true;
	 					}
	 					/* if(spzhifu[i] == $("#input-5").val()){
	 						$("#input-5")[0].checked=true;
	 					}
	 					if(spzhifu[i] == $("#input-6").val()){
	 						$("#input-6")[0].checked=true;
	 					}
	 					if(spzhifu[i] == $("#input-7").val()){
	 						$("#input-7")[0].checked=true;
	 					}
	 					if(spzhifu[i] == $("#input-8").val()){
	 						$("#input-8")[0].checked=true;
	 					} */
		 		 	}
	 			}
	 		}
		}  
	
	$(".btn-primary").on("click",function(){
		$("#editPayOnLine").modal("hide")
		var paytype=[];	
		/* if($("#input-1")[0].checked == true){
			paytype.push($("#input-1").val());
		} */
		if($("#input-2")[0].checked == true){
			paytype.push($("#input-2").val());
		}
		/* if($("#input-3")[0].checked == true){
			paytype.push($("#input-3").val());
		} */
		if($("#input-4")[0].checked == true){
			paytype.push($("#input-4").val());
		}
		/* if($("#input-5")[0].checked == true){
			paytype.push($("#input-5").val());
		}
		if($("#input-6")[0].checked == true){
			paytype.push($("#input-6").val());
		}
		if($("#input-7")[0].checked == true){
			paytype.push($("#input-7").val());
		}
		if($("#input-8")[0].checked == true){
			paytype.push($("#input-8").val());
		} */
		paytype = paytype+",";
		$.ajax({
			 url:"/admin/updateRecharge.do",
			 type:"post",
			 data:{
				 "id":$("#int-id").text(),
				 "payName":$("#input-jiek").val(),
				 "P_UserId":$("#input-shbh").val(),
				 "SalfStr":$("#input-xdmy").val(),
				 "dealerURL":$("#input-zfmy").val(),
				 "minMoney":$("#input-zxje").val(),
				 "maxMoney":$("#input-zdje").val(),
				 "payInterfaceURL":$("#input-zfjkurl").val(),
				 "payQueryURL":$("#input-ydcxdz").val(),
				 "shopName":$("#input-shmc").val(),
				 "P_ChannelId":paytype
			 },
			success:function(data){
				 if(data.data == 1){
					 $("#table-i-onlinePayTable").DataTable().ajax.reload();
				    layer.alert("操作成功!");
				 }
			}	
		})
	});
</script>
</body>
</html>